package com.financing.wap.service.impl;


import java.sql.SQLException;
import java.util.List;

import com.financing.wap.common.CommonConstantUtil;
import com.financing.wap.util.DTOdateSetUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.financing.wap.dto.PrInvoiceDTO;
import com.financing.wap.service.IPrInvoiceService;
import com.financing.wap.dao.IPrInvoiceDao;
/**
 * pr_invoice  
 * 项目发票 业务访问层实现类
 * @author huqiyun
 *
 */
 
@Service("prInvoiceService")
public class PrInvoiceServiceImpl implements IPrInvoiceService{

	@Autowired
	private IPrInvoiceDao prInvoiceDao;

	@Override
	public int insert(PrInvoiceDTO prInvoice) throws SQLException {
		DTOdateSetUtil.setCreateInfo(prInvoice);
		DTOdateSetUtil.setUpdateInfo(prInvoice);
		prInvoice.setDeleteTag(CommonConstantUtil.CommonStatus.DELETE_TAG_NORMAL);
		return prInvoiceDao.insert(prInvoice);
	}

	@Override
	public void update(PrInvoiceDTO prInvoice) throws SQLException {
		DTOdateSetUtil.setUpdateInfo(prInvoice);
		prInvoiceDao.update(prInvoice);
	}

	@Override
	public void updateForce(PrInvoiceDTO prInvoice) throws SQLException {
		DTOdateSetUtil.setUpdateInfo(prInvoice);
		prInvoiceDao.updateForce(prInvoice);
	}

	@Override
	public void delete(Integer id) throws SQLException {
		prInvoiceDao.delete(id);
	}
	
	@Override
	public List<PrInvoiceDTO> queryList(PrInvoiceDTO prInvoice) throws SQLException {
		return prInvoiceDao.queryList(prInvoice);
	}

	@Override
	public int queryListCount(PrInvoiceDTO prInvoice) throws SQLException {
		return prInvoiceDao.queryListCount(prInvoice);
	}

	@Override
	public PrInvoiceDTO loadById(Integer id) throws SQLException {
		return prInvoiceDao.loadById(id);
	}
 	@Override
	public PrInvoiceDTO queryListGetFirst(PrInvoiceDTO prInvoice)
			throws SQLException {
		 List<PrInvoiceDTO> queryList = queryList(prInvoice);
		 if(queryList==null||queryList.size()==0){
			 return new PrInvoiceDTO();
		 }
		 return queryList.get(0);
	}
}
